<?php
namespace App\Utils\Logic\czy;

use App\Models\Agent;
use App\Models\lak\Residential;
use App\Utils\Thirdparty\Map\Amap;

class Map
{
    public static function opiFang($params)
    {
        // 调用高德地图 API 的POI关键词搜索接口
        $amapAdapter = new \App\Utils\Adapter\Map(new Amap());
        $pois =$amapAdapter->opi($params['lat'],$params['lng'],$params['radius'],$params['type']);
        $datas=[];
        //查询数据库 并 重构数据
        foreach ($pois as $poi) {
            $data = Residential::where('location','like','%'.$poi['name'].'%')->get();
            foreach ($data as $key => $val) {
                if ($val->id) $datas[]=$val->toArray();
            }
        }
        return $datas;
    }

}
